package ai.platon.pulsar.persist

import ai.platon.pulsar.common.config.ImmutableConfig
import ai.platon.pulsar.persist.gora.generated.GWebPage
import java.nio.ByteBuffer

abstract class WebDb(
    conf: ImmutableConfig
) : AutoCloseable {
    abstract fun get(url: String, b: Boolean): WebPage?
    abstract fun getOrNull(url: String, b: Boolean): WebPage?
    abstract fun getContent(url: String): ByteBuffer?
    abstract fun getContentAsString(url: String): String?
    abstract fun exists(url: String): Any
    abstract fun put(page: WebPage, b: Boolean)
    abstract fun delete(url: String)
    abstract fun get(originalUrl: String, norm: Boolean = false, fields: Array<String>? = null): WebPage
    abstract fun scan(urlPrefix: String, fields: Iterable<GWebPage.Field>): Iterator<WebPage>?
    abstract fun getOrNull(originalUrl: String, norm: Boolean = false, fields: Array<String>? = null): WebPage?
    abstract fun scan(urlBase: String, fields: Array<String>): Iterator<WebPage>
    abstract fun flush()
    abstract fun scan(urlPrefix: String): Iterator<WebPage>?
    abstract fun put(page: WebPage):Boolean
    abstract fun schemaName(): String?
    abstract fun canConnect(): Boolean
    abstract fun get0(url: String, b: Boolean, arrayOf: Array<String>): GWebPage?
    abstract fun getOrNull(originalUrl: String, fields: Iterable<GWebPage.Field>): WebPage?
    abstract fun getOrNull(url: String, content: GWebPage.Field): WebPage?


}
